<template>
  <ex_select_auto ref="main" :option="option" filterable remote :remoteQuery="remoteQueryFun" :url="url" :value="value" :disabled="disabled"
  :reserve-keyword="true" default-first-option
    :urlParams="urlParams" :dependentId="customerId" :clearable="true" v-bind="$attrs" v-on="$listeners" />
</template>
<script>
import Vue from 'vue'
import role_system_mixin from '@/mixin/role_system_mixin';

export default {
  mixins: [role_system_mixin,],

  data() {
    return {
      url: '/oms-api/purchase/OmsPurchaseSupplierRpc/selectPage.json'
    }
  },
  props: {
    value: null,
    customerId: {
      type: [Number, String],
      default: null,
    },
    disabled: {
      type: Boolean,
      default: false
    },
    option: {
      type: [Object, Function],
      default: () => {
        return function (it) {
          return { label: Vue.prototype.$formatNameCode(it.supplierName, it.supplierCode), value: it['id'] }
        }
      }
    },
  },
  created() {
  },
  methods: {
    urlParams() {
      let params = {
        pageSize:9999,
        pageIndex:1
      }
      if (this.customerId) params.customerId = this.customerId
      return params
    },
    remoteQueryFun(query) {
      const data = {}
      if (query.trim() !== '') {
        data.supplierName = query.trim()
      }
      return data
    },


  },
}
</script>
